package com.ms.p2p.service.impl;


import com.ms.p2p.bean.PageBean;
import com.ms.p2p.dao.LoanDueInDao;
import com.ms.p2p.entity.loan.LoanDueIn;
import com.ms.p2p.provider.LoanTenderRecordProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class LoanDueInServiceImpl {

	@Autowired
	private LoanTenderRecordServiceImpl bts;
	@Autowired
	private LoanDueInDao borrowDueInDao;

	/**
	 * 根据投标ID和对应期数查出待收数据
	 *
	 * @param tend_id
	 * @param order
	 * @return
	 */
	public LoanDueIn findByTenderIdAndOrder(int tend_id, int order) {
		HashMap<String,Object> map = new HashMap<String,Object>();
		map.put("order", order);
		map.put("tender_id", tend_id);
		map.put("status",0);
		return borrowDueInDao.find(map);

	}
	public List<LoanDueIn> findByBorrowIdAndOrder(int loanid, int stay_periods) {
		HashMap<String,Object> map = new HashMap<String,Object>();
		map.put("order", stay_periods);
		map.put("loan_id", loanid);
		map.put("status",0);
		return borrowDueInDao.findDueInList(map);

	}


	/**
	 * 增
	 * 
	 * @param map
	 * @return
	 */
	public int insert(LoanDueIn map) {
		return borrowDueInDao.insert(map);

	}


	public int update(LoanDueIn map) {
		return borrowDueInDao.update(map);
	}

	public  List<Map<String,Object>> findPager(Integer id, String status, PageBean page){
		return borrowDueInDao.findPager(id,status,page.getBegin(),page.getPageSize());
	}
	public int findCount(Integer id, String status) {
		return borrowDueInDao.findCount(id,status);
	}


	public String getIncome(Integer id,Integer status) {
		return borrowDueInDao.findIncome(id,status);
	}

	public int getcount(Integer id, int i) {
		{
			return borrowDueInDao.getcount(id,i);
	}
}


}
